 <?php
include "connect/toolconnect.php"; 
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'ID';
$order = isset($_POST['order']) ? strval($_POST['order']) : 'asc';
$offset = ($page-1)*$rows;
$result = array();
$rs = mysql_query("select count(*) from ".$_GET['class1'] );
$row = mysql_fetch_row($rs);
$result["total"] = $row[0];
$rs = mysql_query("select * from ".$_GET['class1']." order by $sort $order  limit $offset,$rows");
$items = array();
while($row = mysql_fetch_object($rs)){
	array_push($items, $row);
}
$result["rows"] = $items;
echo json_encode($result);
?>	

